package executors;
import java.util.ArrayList;

import objects.Command;
import objects.Result;
import objects.SortedEventList;
import objects.Event;


public class DeleteExecutor {

        public static Result execute(Command command, SortedEventList data, SortedEventList completeTasks) {
                ArrayList<Event> list = new ArrayList<Event>();
                int id = command.getId();
                boolean isSuccessful = false;
                try {
                       for (int i = 0; i<data.size(); i++){
                    	   if (data.get(i).getId()==id){
                    		   list.add(data.get(i));
                    		   isSuccessful = data.remove(i);
                    		   break;
                    	   }  
                       }
                       return new Result(isSuccessful, list);
                       
                } catch (Exception e){
                        return new Result(false, list, null, e.toString());
                }

        }


}
